package com.example.motion.controller;

import com.example.motion.config.ResultT;
import com.example.motion.model.MotionOffice;
import com.example.motion.service.IMotionOfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <br>Title:
 * <br>Description:
 * <br>Author:
 * <br>Date:
 */
@RestController
public class MotionOfficeController {

    @Autowired
    private IMotionOfficeService motionOfficeService;

    /**
     * 获取分局信息
     * @return
     */
    @PostMapping("/getMotionOfficeList")
    public ResultT getMotionOfficeList() {
        try {
            List<MotionOffice> motionOfficeList = motionOfficeService.getOfficeList();
            return ResultT.ok(motionOfficeList);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultT.error();
        }
    }
    /**
     * 获取分局信息简介
     * @return
     */
    @GetMapping("/getMotionOfficeIntroduce")
    public ResultT getMotionOfficeIntroduce(@RequestParam("code") String code) {
        try {
            MotionOffice motionOffice = motionOfficeService.getMotionOfficeIntroduce(code);
            return ResultT.ok(motionOffice);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultT.error();
        }
    }
}
